﻿

Public Class ZipperFormPanel


    'Design Zip Creation Event :
    Private Sub ZD_ZipCreationRequested(sender As Object, e As ZipCreationRequestedEventArgs) Handles ZD.ZipCreationRequested
        Me.SuspendLayout()
        ZD.Visible = False
        ZPV.Visible = True
        ZPV.BringToFront()
        ZPV.CreateZip(e.Location, ZD.Setter.PF.Filters)
        Me.ResumeLayout()
    End Sub
    'Progress Events :
    Private Sub ZPV_ProgressAbortRequired(sender As Object, e As System.EventArgs) Handles ZPV.ProgressAbortRequired
        RaiseEvent ZipCreationAbortRequested(Me, e)
    End Sub
    Private Sub ZPV_ProgressCancelRequired(sender As Object, e As System.EventArgs) Handles ZPV.ProgressCancelRequired
        Me.SuspendLayout()
        ZD.Visible = True
        ZD.Designer.SelectNode(ZD.Designer.RootZipNode)
        ZD.Designer.KHG.ValuesPrimary.Description = ""
        ZPV.Visible = False
        ZD.BringToFront()
        Me.ResumeLayout()
    End Sub
    Private Sub ZPV_ProgressSavingError(sender As Object, e As ZipSavingErrorOccuredEventArgs) Handles ZPV.ProgressSavingError
        Me.SuspendLayout()
        KryptonMessageBox.Show("Zip Creation Error Occured : " & vbNewLine & e.OccuredError.Message, _
                               "Zipper - Error", _
                               MessageBoxButtons.OK, MessageBoxIcon.Error)
        ZD.Designer.SelectNode(ZD.Designer.RootZipNode)
        ZD.Designer.KHG.ValuesPrimary.Description = ""
        ZD.Visible = True
        ZPV.Visible = False
        ZD.BringToFront()
        Me.ResumeLayout()
    End Sub
    Private Sub ZPV_ProgressSavingFinished(sender As Object, e As ZipSavingFinishedEventArgs) Handles ZPV.ProgressSavingFinished
        Dim temps As List(Of String) = ZD.Designer.TempsLocations
        For Each Loc As String In temps
            IO.Directory.Delete(Loc, True)
        Next
        RaiseEvent ZipCreationFinished(Me, e)
    End Sub
    Public Event ZipCreationAbortRequested As EventHandler(Of EventArgs)
    Public Event ZipCreationFinished As EventHandler(Of EventArgs)

End Class
